﻿/*
 * ===================================================
 * Author     : <ClueeZhuo>
 * Create Time: <2018/5/22 15:31:51>
 * Description: <This is a Description of This File.>
 * ===================================================
 */



using DotNetCore.CAP;
using Microsoft.AspNetCore.Mvc;
using System.Data.SqlClient;
using System.Threading.Tasks;

namespace helloworld.Controllers
{
    public class PublishController : Controller
    {
        private readonly ICapPublisher _publisher;

        public PublishController(ICapPublisher capPublisher)
        {
            this._publisher = capPublisher;
        }

        /// <summary>
        /// Publish
        /// </summary>
        /// <returns></returns>
        [Route("~/Publish")]
        public async Task<IActionResult> Publish()
        {
            _publisher.Publish("xxx.services.account.check", new object());

            return Ok();
        }

        /// <summary>
        /// PublishAsync
        /// </summary>
        /// <returns></returns>
        [Route("~/PublishAsync")]
        public async Task<IActionResult> PublishAsync()
        {
            await _publisher.PublishAsync("xxx.services.account.check", new object(), "callBackName");

            return Ok();
        }

        [CapSubscribe("xxx.services.bar")]
        public void BarMessageProcessor()
        {

        }

        [CapSubscribe("xxx.services.bar")]
        [CapSubscribe("xxx.services.foo")]
        public void BarAndFooMessageProcessor()
        {

        }
    }
}
